Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using reghdfe for a fixed effect gravity model |

    Hey there,
    Im using Stata pretty much the first time and I want to create a regression regarding a gravity model about how the exports of Croatia have changed regarding there EU accession.

    Im using the International Trade and Production Database for Estimation (ITPD-E) and Dynamic Gravity Dataset (DGD) datasets, summed the trades, since I dont need them at the industry level and just keeped Croatia as an exporter. Ive merged the two datasets, using the exporter, importer and year, into one dataset, which contains data about croatias exports in every country for 1992 - 2019 and the gravity variables for the countries.
    Ive also transformed some variables using logarithm. And Ive created a variable (imp_exp) which grouped the exporter and importer, which I want to call in the reghdfe as an absorb.

    My regression call is:
    Using simple OLS:
    reg lntrade lngdp_d lndistance contiguity common_language member_eu_d member_eu_joint
    Click image for larger version

Name:	ols.png
Views:	1
Size:	20.0 KB
ID:	1741097



    Using fixed effects:
    reghdfe lntrade lngdp_d lndistance contiguity common_language member_eu_d member_eu_joint, absorb(imp_exp) noconst
    Click image for larger version

Name:	fixed effects.png
Views:	1
Size:	31.0 KB
ID:	1741098




    Different approach:
    So far so good I assume.
    Now, since Im interested in the EU accession, which happend in 2013, I wanted to just include 2012 and 2014 as years, so I can observe any difference in before EU accession and right after.


    Using simple OLS:
    Click image for larger version

Name:	ols_.png
Views:	1
Size:	19.9 KB
ID:	1741099



    Using fixed effects:
    Click image for larger version

Name:	fixed effects_.png
Views:	1
Size:	30.9 KB
ID:	1741100




    My question is, if Ive used the fixed effects in the right way and if its oaky to just use 2012 & 2014 as years, since now even the GDP of the other country isnt significant. I could understand that the EU dummies are insignificant since Croatia had some trade agreements with EU countries before the EU accession.
    Or how would you estimate the change in trade/export regarding the EU accession.



    Or could I just say, using the two different approaches, that in genral the trade between 1992 - 2019 is determinant by GDP of the other country, distance, contiguity, common_language and if the other country is in the EU, or, by using fixed effects, is determinant by the GDP of the other country and if the country is in the EU.
    And, looking just at 2012 & 2014, regarding the EU accession of Croatia there are no changes in the trade behaviour.





    Best regards


    Code:
    *******************************
    ***** Installing Packages *****
    *******************************
    
    ssc install reghdfe
    ssc install ftools
    
    
    **************************
    ***** Importing Data *****
    **************************
    
    ***** Gravity Variables********
    insheet using "release_2.0_2000_2016.csv", clear
    save "gravity_variables.dta", replace
    
    
    ***** Trade Data *****
    insheet using "ITPD_E_R02.csv", clear
    keep trade exporter_iso3 exporter_name importer_iso3 importer_name year
    collapse (sum) trade, by(exporter_iso3 exporter_name importer_iso3 importer_name year)
    rename exporter_iso3 iso3_o
    rename importer_iso3 iso3_d
    keep if iso3_o == "HRV"
    save "trade_data.dta", replace
    
    
    **************************
    ***** Merge Datasets *****
    **************************
    
    use "trade_data.dta", clear
    drop exporter_name importer_name
    merge 1:1 iso3_o iso3_d year using "gravity_variables.dta"
    drop if _merge == 2
    save "trade_with_gravity.dta"
    
    
    ****************************
    ***** First Regression *****
    ****************************
    
    use "trade_with_gravity.dta", clear
    
    * Regarding if you want to observer only 2012 & 2014
    drop if year > 2014
    drop if year < 2012
    drop if year == 2013
    
    
    * Transforming variables
    gen lntrade = ln(trade)
    gen lngdp_o = ln(gdp_wdi_const_o)
    gen lngdp_d = ln(gdp_wdi_const_d)
    gen lndistance = ln(distance)
    egen exp_year = group(iso3_o year)
    
    egen imp_year = group(iso3_d year)
    egen imp_exp = group(iso3_o iso3_d)
    
    
    * Regression using OLS
    reg lntrade lngdp_d lndistance contiguity common_language member_eu_d member_eu_joint
    
    
    * Regression using fixed effects
    reghdfe lntrade lngdp_d lndistance contiguity common_language member_eu_d member_eu_joint, absorb(imp_exp) noconst
    Last edited by Paul Friedrich; 25 Jan 2024, 05:12.

  • #2
    Paul:
    have you taken a look at Joao Santos Silva 's posts on this topic?
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Hey Carlo Lazzaro,
      thanks for your reply. Ive read a few posts in this forum about gravity models and fixed effects, but I couldnt find the right one for my problem.
      Ive already noted that a Poisson regression using ppmlhdfe seems to be a better model or estimator for a gravity model, but I need to stick to the reghdfe approach for a while.

      Kind regards
      Paul

      Comment

      Working...
      X